[Local catalog] Prevent duplicated attributes in variation names #16399
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

Description
This PR prevents variations from getting duplicated attributes in their names.
Previously, if a variable product was edited, its attributes would be added to the database again on the next incremental sync. This resulted in its variation's names showing the same components multiple times, making it harder to fit and identify a variation by name.
Cause
Attributes were duplicated in the database because although we use
save, which upserts items, they wouldn't update, because they use an auto-incremented primary key. This is due to "local attributes" all having an ID of 0 (local to the product, not related to local catalog.)GRDB identified the attributes as new, and inserted them instead, which meant that the calculation of the variation's name pulled in all the copies of the attribuet.
Fix
To fix this, we simply delete all attributes for updated products before inserting them again during incremental syncs. The catalog always includes all attributes, even if they're unchanged, so this is safe (unlike with variations.)
Test Steps
N.B. I noticed that changes to attributes don't trigger observation updates for variation names which should change, which is why you need to exit and reopen POS to see the changes. I'll fix that separately.
RELEASE-NOTES.txtif necessary.